package com.example.demo.controller;

import com.example.demo.service.ManageGoods;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Controller
@Api(value = "后台商品展示",tags = "后台商品展示页")
@RequestMapping("/ManageGoods")
public class ManageGoodsSearch {

    @Autowired
    ManageGoods manageGoods;



    @ApiOperation(value = "商品上下架",tags = "商品上下架")
    @RequestMapping(value = "/statusChange",method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "saleststus",value = "上下架状态"),
            @ApiImplicitParam(name = "goodsid",value = "商品id")
       })
    public String changeStatus(int goodsid,int saleststus ){
        if(saleststus==1){
            System.out.println("1111");
            manageGoods.update(goodsid,saleststus);
            manageGoods.addRedies(goodsid);
            return "redirect:/goodsUpload/goodsmessage";
            }else {
            manageGoods.update(goodsid,saleststus);
            manageGoods.deleteRediesGood(goodsid);
            return "redirect:/goodsUpload/goodsmessage";
        }
    }





}
